home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Cross Platform / QuickTime 4.1.2 Windows SDK / CIncludes / ATA.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-12  |  58.0 KB  |  1,113 lines  |  [TEXT/R*ch]

  1. /*
  2.      File:        ATA.h
  3.  
  4.      Contains:    ATA (PC/AT Attachment) Interfaces
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    QuickTime 4.1
  8.  
  9.      Copyright:    (c) 1995-1999 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __ATA__
  18. #define __ATA__
  19.  
  20. #ifndef __MACTYPES__
  21.     #include <MacTypes.h>
  22. #endif
  23.  
  24. #ifndef __MIXEDMODE__
  25.     #include <MixedMode.h>
  26. #endif
  27.  
  28.  
  29.  
  30.  
  31. #if PRAGMA_ONCE
  32. #pragma once
  33. #endif
  34.  
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38.  
  39. #if PRAGMA_IMPORT
  40. #pragma import on
  41. #endif
  42.  
  43. #if PRAGMA_STRUCT_ALIGN
  44.     #pragma options align=mac68k
  45. #elif PRAGMA_STRUCT_PACKPUSH
  46.     #pragma pack(push, 2)
  47. #elif PRAGMA_STRUCT_PACK
  48.     #pragma pack(2)
  49. #endif
  50.  
  51.  
  52. /* This is the structure used for the AT Interface core routines below */
  53. enum {
  54.     kATATrap                    = 0xAAF1,                        /* Manager trap number <This should be defined in Traps.h>*/
  55.     kATAPBVers1                    = 0x01,                            /* parameter block version number 1*/
  56.     kATAPBVers2                    = 0x02,                            /* parameter block version number for structures*/
  57.     kATAPBVers3                    = 0x03,                            /* parameter block version for ATA times*/
  58.     kATADefaultBlockSize        = 512                            /* default block size*/
  59. };
  60.  
  61. /* Used to determine the presence of traps*/
  62. enum {
  63.     kFSMTrap                    = 0xAC,
  64.     mDQEChanged                    = 1                                /* DQE has changed */
  65. };
  66.  
  67. /* Task file definition ooo Error Register ooo*/
  68. enum {
  69.     bATABadBlock                = 7,                            /* bit number of bad block error bit*/
  70.     bATAUncorrectable            = 6,                            /* bit number of uncorrectable error bit*/
  71.     bATAMediaChanged            = 5,                            /* bit number of media changed indicator*/
  72.     bATAIDNotFound                = 4,                            /* bit number of ID not found error bit*/
  73.     bATAMediaChangeReq            = 3,                            /* bit number of media changed request*/
  74.     bATACommandAborted            = 2,                            /* bit number of command abort bit*/
  75.     bATATrack0NotFound            = 1,                            /* bit number of track not found*/
  76.     bATAAddressNotFound            = 0,                            /* bit number of address mark not found*/
  77.     mATABadBlock                = 1 << bATABadBlock,            /* Bad Block Detected*/
  78.     mATAUncorrectable            = 1 << bATAUncorrectable,        /* Uncorrectable Data Error*/
  79.     mATAMediaChanged            = 1 << bATAMediaChanged,        /* Media Changed Indicator (for removable)*/
  80.     mATAIDNotFound                = 1 << bATAIDNotFound,            /* ID Not Found*/
  81.     mATAMediaChangeReq            = 1 << bATAMediaChangeReq,        /* Media Change Requested (NOT IMPLEMENTED)*/
  82.     mATACommandAborted            = 1 << bATACommandAborted,        /* Aborted Command*/
  83.     mATATrack0NotFound            = 1 << bATATrack0NotFound,        /* Track 0 Not Found*/
  84.     mATAAddressNotFound            = 1 << bATAAddressNotFound        /* Address Mark Not Found*/
  85. };
  86.  
  87. /* Task file definition ooo Features register ooo*/
  88. enum {
  89.     bATAPIuseDMA                = 0,                            /* bit number of useDMA bit (ATAPI)*/
  90.     mATAPIuseDMA                = 1 << bATAPIuseDMA
  91. };
  92.  
  93. /* Task file definition ooo ataTFSDH Register ooo*/
  94. enum {
  95.     mATAHeadNumber                = 0x0F,                            /* Head Number (bits 0-3) */
  96.     mATASectorSize                = 0xA0,                            /* bit 7=1; bit 5 = 01 (512 sector size) <DP4>*/
  97.     mATADriveSelect                = 0x10,                            /* Drive (0 = master, 1 = slave) */
  98.     mATALBASelect                = 0x40                            /* LBA mode bit (0 = chs, 1 = LBA)*/
  99. };
  100.  
  101. /* Task file definition ooo Status Register ooo*/
  102. enum {
  103.     bATABusy                    = 7,                            /* bit number of BSY bit*/
  104.     bATADriveReady                = 6,                            /* bit number of drive ready bit*/
  105.     bATAWriteFault                = 5,                            /* bit number of write fault bit*/
  106.     bATASeekComplete            = 4,                            /* bit number of seek complete bit*/
  107.     bATADataRequest                = 3,                            /* bit number of data request bit*/
  108.     bATADataCorrected            = 2,                            /* bit number of data corrected bit*/
  109.     bATAIndex                    = 1,                            /* bit number of index mark*/
  110.     bATAError                    = 0,                            /* bit number of error bit*/
  111.     mATABusy                    = 1 << bATABusy,                /* Unit is busy*/
  112.     mATADriveReady                = 1 << bATADriveReady,            /* Unit is ready*/
  113.     mATAWriteFault                = 1 << bATAWriteFault,            /* Unit has a write fault condition*/
  114.     mATASeekComplete            = 1 << bATASeekComplete,        /* Unit seek complete*/
  115.     mATADataRequest                = 1 << bATADataRequest,            /* Unit data request*/
  116.     mATADataCorrected            = 1 << bATADataCorrected,        /* Data corrected*/
  117.     mATAIndex                    = 1 << bATAIndex,                /* Index mark - NOT USED*/
  118.     mATAError                    = 1 << bATAError                /* Error condition - see error register*/
  119. };
  120.  
  121. /* Task file definition ooo Device Control Register ooo*/
  122. enum {
  123.     bATADCROne                    = 3,                            /* bit number of always one bit*/
  124.     bATADCRReset                = 2,                            /* bit number of reset bit*/
  125.     bATADCRnIntEnable            = 1,                            /* bit number of interrupt disable*/
  126.     mATADCROne                    = 1 << bATADCROne,                /* always one bit*/
  127.     mATADCRReset                = 1 << bATADCRReset,            /* Reset (1 = reset)*/
  128.     mATADCRnIntEnable            = 1 << bATADCRnIntEnable        /* Interrupt Disable(0 = enabled)*/
  129. };
  130.  
  131. /* ATA Command Opcode definition*/
  132. enum {
  133.     kATAcmdWORetry                = 0x01,                            /* Without I/O retry option*/
  134.     kATAcmdNOP                    = 0x0000,                        /* NOP operation - media detect*/
  135.     kATAcmdRecal                = 0x0010,                        /* Recalibrate command */
  136.     kATAcmdRead                    = 0x0020,                        /* Read command */
  137.     kATAcmdReadLong                = 0x0022,                        /* Read Long command*/
  138.     kATAcmdWrite                = 0x0030,                        /* Write command */
  139.     kATAcmdWriteLong            = 0x0032,                        /* Write Long*/
  140.     kATAcmdWriteVerify            = 0x003C,                        /* Write verify*/
  141.     kATAcmdReadVerify            = 0x0040,                        /* Read Verify command */
  142.     kATAcmdFormatTrack            = 0x0050,                        /* Format Track command */
  143.     kATAcmdSeek                    = 0x0070,                        /* Seek command */
  144.     kATAcmdDiagnostic            = 0x0090,                        /* Drive Diagnostic command */
  145.     kATAcmdInitDrive            = 0x0091,                        /* Init drive parameters command */
  146.     kATAcmdReadMultiple            = 0x00C4,                        /* Read multiple*/
  147.     kATAcmdWriteMultiple        = 0x00C5,                        /* Write multiple*/
  148.     kATAcmdSetRWMultiple        = 0x00C6,                        /* Set Multiple for Read/Write Multiple*/
  149.     kATAcmdReadDMA                = 0x00C8,                        /* Read DMA (with retries)*/
  150.     kATAcmdWriteDMA                = 0x00CA,                        /* Write DMA (with retries)*/
  151.     kATAcmdMCAcknowledge        = 0x00DB,                        /* Acknowledge media change - removable*/
  152.     kATAcmdDoorLock                = 0x00DE,                        /* Door lock*/
  153.     kATAcmdDoorUnlock            = 0x00DF,                        /* Door unlock*/
  154.     kATAcmdStandbyImmed            = 0x00E0,                        /* Standby Immediate*/
  155.     kATAcmdIdleImmed            = 0x00E1,                        /* Idle Immediate*/
  156.     kATAcmdStandby                = 0x00E2,                        /* Standby*/
  157.     kATAcmdIdle                    = 0x00E3,                        /* Idle*/
  158.     kATAcmdReadBuffer            = 0x00E4,                        /* Read sector buffer command */
  159.     kATAcmdCheckPowerMode        = 0x00E5,                        /* Check power mode command    <04/04/94>*/
  160.     kATAcmdSleep                = 0x00E6,                        /* Sleep*/
  161.     kATAcmdWriteBuffer            = 0x00E8,                        /* Write sector buffer command */
  162.     kATAcmdWriteSame            = 0x00E9,                        /* Write same data to multiple sectors*/
  163.     kATAcmdDriveIdentify        = 0x00EC,                        /* Identify Drive command */
  164.     kATAcmdMediaEject            = 0x00ED,                        /* Media Eject*/
  165.     kATAcmdSetFeatures            = 0x00EF                        /* Set Features*/
  166. };
  167.  
  168. /* Set feature command opcodes*/
  169. enum {
  170.     kATAEnableWriteCache        = 0x02,                            /*        Enable write cache*/
  171.     kATASetTransferMode            = 0x03,                            /*        Set transfer mode*/
  172.     kATASetPIOMode                = 0x08,                            /*        PIO Flow Control Tx Mode bit*/
  173.     kATAEnableECC                = 0x88,                            /*        ECC enable*/
  174.     kATAEnableRetry                = 0x99,                            /*        Retry enable*/
  175.     kATAEnableReadAhead            = 0xAA                            /*        Read look-ahead enable*/
  176. };
  177.  
  178. /*
  179.   --------------------------------------------------------------------------------
  180.    enums for dealing with device IDs
  181. */
  182.  
  183. enum {
  184.     kATABusIDMask                = 0x000000FF,
  185.     kATADeviceIDMask            = 0x0000FF00,
  186.     kATADeviceIDClippingMask    = 0x0000FFFF,
  187.     kMinBusID                    = 0x00000000,
  188.     kMaxBusID                    = 0x000000FE
  189. };
  190.  
  191. enum {
  192.     kATAStartIterateDeviceID    = 0xFFFF,
  193.     kATAEndIterateDeviceID        = 0xFF
  194. };
  195.  
  196. /*--------------------------------------------------------------------------------*/
  197. /* Device Register Images  (8 bytes) */
  198.  
  199. struct ataTaskFile {
  200.     UInt8                             ataTFFeatures;                /* <-> Error(R) or ataTFFeatures(W) register image */
  201.     UInt8                             ataTFCount;                    /* <-> Sector count/remaining */
  202.     UInt8                             ataTFSector;                /* <-> Sector start/finish */
  203.     UInt8                             ataTFReserved;                /* reserved                    */
  204.     UInt16                             ataTFCylinder;                /* <-> ataTFCylinder (Big endian) */
  205.     UInt8                             ataTFSDH;                    /* <-> ataTFSDH register image*/
  206.     UInt8                             ataTFCommand;                /* <-> Status(R) or Command(W) register image */
  207. };
  208. typedef struct ataTaskFile                ataTaskFile;
  209. /* ATA Manager Function Code Definition*/
  210. enum {
  211.     kATAMgrNOP                    = 0x00,                            /* No Operation*/
  212.     kATAMgrExecIO                = 0x01,                            /* Execute ATA I/O*/
  213.     kATAMgrBusInquiry            = 0x03,                            /* Bus Inquiry*/
  214.     kATAMgrQRelease                = 0x04,                            /* I/O Queue Release*/
  215.     kATAMgrAbort                = 0x10,                            /* Abort command*/
  216.     kATAMgrBusReset                = 0x11,                            /* Reset ATA bus*/
  217.     kATAMgrRegAccess            = 0x12,                            /* Register Access*/
  218.     kATAMgrDriveIdentify        = 0x13,                            /* Drive Identify            <DP03/10/94>*/
  219.     kATAMgrDriverLoad            = 0x82,                            /* Load driver from either Media, ROM, etc.*/
  220.     kATAMgrDriveRegister        = 0x85,                            /* Register a driver        <4/18/94>*/
  221.     kATAMgrFindDriverRefnum        = 0x86,                            /* lookup a driver refnum    <4/18/94>*/
  222.     kATAMgrRemoveDriverRefnum    = 0x87,                            /* De-register a driver    <4/18/94>*/
  223.     kATAMgrModifyEventMask        = 0x88,                            /* Modify driver event mask*/
  224.     kATAMgrDriveEject            = 0x89,                            /* Eject the drive        <8/1/94>*/
  225.     kATAMgrGetDrvConfiguration    = 0x8A,                            /* Get device configuration    <8/6/94>*/
  226.     kATAMgrSetDrvConfiguration    = 0x8B,                            /* Set device configuration <8/6/94>*/
  227.     kATAMgrGetLocationIcon        = 0x8C,                            /* Get card location icon    <SM4>*/
  228.     kATAMgrManagerInquiry        = 0x90,                            /* Manager Inquiry*/
  229.     kATAMgrManagerInit            = 0x91,                            /* Manager initialization*/
  230.     kATAMgrManagerShutdown        = 0x92,                            /* Manager ShutDown*/
  231.                                                                 /* note: functions 0x93 to 0x97 are reserved*/
  232.     kATAMgrFindSpecialDriverRefnum = 0x98,                        /* lookup a driver refnum; driverloader,notify-all or ROM driver.*/
  233.     kATAMgrNextAvailable        = 0x99
  234. };
  235.  
  236. /* used in the ataDrvrFlags field for kATAMgrDriveRegister,kATAMgrRemoveDriverRefnum & kATAMgrFindSpecialDriverRefnum*/
  237. enum {
  238.     kATANotifyAllDriver            = 0,                            /* Notify-All driver*/
  239.     kATADriverLoader            = 1,                            /* Driver loader driver        */
  240.     kATAROMDriver                = 2                                /* ROM driver*/
  241. };
  242.  
  243. /* 'ATAFlags' field of the PB header definition*/
  244. enum {
  245.     bATAFlagUseConfigSpeed        = 15,                            /* bit number of use default speed flag*/
  246.     bATAFlagByteSwap            = 14,                            /* bit number of byte swap flag*/
  247.     bATAFlagIORead                = 13,                            /* bit number of I/O read flag*/
  248.     bATAFlagIOWrite                = 12,                            /* bit number of I/O write flag*/
  249.     bATAFlagImmediate            = 11,                            /* bit number of immediate flag*/
  250.     bATAFlagQLock                = 10,                            /* bit number of que lock on error*/
  251.     bATAFlagReserved1            = 9,                            /* reserved*/
  252.     bATAFlagUseScatterGather    = 8,                            /* bit numbers of scatter gather*/
  253.     bATAFlagUseDMA                = 7,                            /* bit number of use DMA flag*/
  254.     bATAFlagProtocolATAPI        = 5,                            /* bit number of ATAPI protocol*/
  255.     bATAFlagReserved2            = 4,                            /* reserved*/
  256.     bATAFlagTFRead                = 3,                            /* bit number of register update*/
  257.     bATAFlagLEDEnable            = 0,                            /* bit number of LED enable*/
  258.     mATAFlagUseConfigSpeed        = 1 << bATAFlagUseConfigSpeed,
  259.     mATAFlagByteSwap            = 1 << bATAFlagByteSwap,        /* Swap data bytes (read - after; write - before)*/
  260.     mATAFlagIORead                = 1 << bATAFlagIORead,            /* Read (in) operation*/
  261.     mATAFlagIOWrite                = 1 << bATAFlagIOWrite,            /* Write (out) operation*/
  262.     mATAFlagImmediate            = 1 << bATAFlagImmediate,        /* Head of Que; Immediate operation*/
  263.     mATAFlagQLock                = 1 << bATAFlagQLock,            /* Manager queue lock on error (freeze the queue)*/
  264.     mATAFlagUseScatterGather    = 1 << bATAFlagUseScatterGather, /* Scatter gather enable*/
  265.     mATAFlagUseDMA                = 1 << bATAFlagUseDMA,
  266.     mATAFlagProtocolATAPI        = 1 << bATAFlagProtocolATAPI,    /* ATAPI protocol indicator*/
  267.     mATAFlagTFRead                = 1 << bATAFlagTFRead,            /* update reg block request upon detection of an error*/
  268.     mATAFlagLEDEnable            = 1 << bATAFlagLEDEnable        /* socket LED enable*/
  269. };
  270.  
  271. /* These are legacy ATAFlags definitions, which will go away in the future*/
  272. enum {
  273.     bATAFlagScatterGather1        = bATAFlagReserved1,            /* 9*/
  274.     bATAFlagScatterGather0        = bATAFlagUseScatterGather,        /* 8*/
  275.     bATAFlagProtocol1            = bATAFlagProtocolATAPI,        /* 5*/
  276.     bATAFlagProtocol0            = bATAFlagReserved2,            /* 4*/
  277.     mATAFlagScatterGather1        = 1 << bATAFlagScatterGather1,
  278.     mATAFlagScatterGather0        = mATAFlagUseScatterGather,
  279.     mATAFlagScatterGathers        = mATAFlagScatterGather1 + mATAFlagScatterGather0,
  280.     mATAFlagProtocol1            = mATAFlagProtocolATAPI,
  281.     mATAFlagProtocol0            = 1 << bATAFlagProtocol0,
  282.     mATAFlagProtocols            = mATAFlagProtocol1 + mATAFlagProtocol0
  283. };
  284.  
  285.  
  286. typedef CALLBACK_API( void , ATACallbackProcPtr )(void *ataPB);
  287. typedef STACK_UPP_TYPE(ATACallbackProcPtr)                         ATACallbackUPP;
  288. #if OPAQUE_UPP_TYPES
  289.     EXTERN_API(ATACallbackUPP)
  290.     NewATACallbackUPP               (ATACallbackProcPtr        userRoutine);
  291.  
  292.     EXTERN_API(void)
  293.     DisposeATACallbackUPP           (ATACallbackUPP            userUPP);
  294.  
  295.     EXTERN_API(void)
  296.     InvokeATACallbackUPP           (void *                    ataPB,
  297.                                     ATACallbackUPP            userUPP);
  298.  
  299. #else
  300.     enum { uppATACallbackProcInfo = 0x000000C0 };                     /* pascal no_return_value Func(4_bytes) */
  301.     #define NewATACallbackUPP(userRoutine)                             (ATACallbackUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppATACallbackProcInfo, GetCurrentArchitecture())
  302.     #define DisposeATACallbackUPP(userUPP)                             DisposeRoutineDescriptor(userUPP)
  303.     #define InvokeATACallbackUPP(ataPB, userUPP)                     CALL_ONE_PARAMETER_UPP((userUPP), uppATACallbackProcInfo, (ataPB))
  304. #endif
  305. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  306. #define NewATACallbackProc(userRoutine)                         NewATACallbackUPP(userRoutine)
  307. #define CallATACallbackProc(userRoutine, ataPB)                    InvokeATACallbackUPP(ataPB, userRoutine)
  308. /*
  309.    
  310.    structure which defines the ATA bus/device ID, part of the Device 0/1 Software Guide
  311.    see <http://developer.apple.com/techpubs/hardware/Developer_Notes/System_Software/ATA_Device_Zero_One.pdf>
  312.    p 19 :     Although ataPBDeviceID remains defined as a 32-bit number, drivers and applications
  313.             can typecast it to the ataDeviceID structure to determine the bus number and device number
  314.               for a specific ATA or ATAPI device
  315. */
  316.  
  317. struct ataDeviceID {
  318.     UInt16                             Reserved;                    /* The upperword is reserved (0)*/
  319.     UInt8                             devNum;                        /* device number (0 or 1)*/
  320.     UInt8                             busNum;                        /* bus number*/
  321. };
  322. typedef struct ataDeviceID                ataDeviceID;
  323.  
  324. struct ataPBHeader {
  325.                                                                 /* Start of cloned common header ataPBHdr */
  326.     struct ataPBHeader *            ataPBLink;                    /* a pointer to the next entry in the queue    */
  327.     UInt16                             ataPBQType;                    /* type byte for safety check*/
  328.     UInt8                             ataPBVers;                    /* -->: parameter block version number*/
  329.     UInt8                             ataPBReserved;                /* Reserved                                        */
  330.     Ptr                             ataPBReserved2;                /* Reserved                                        */
  331.     ATACallbackUPP                     ataPBCallbackPtr;            /* -->: Completion Routine Pointer*/
  332.     OSErr                             ataPBResult;                /* <--: Returned result                */
  333.     UInt8                             ataPBFunctionCode;            /* -->: Manager Function Code */
  334.     UInt8                             ataPBIOSpeed;                /* -->: I/O Timing Class            */
  335.     UInt16                             ataPBFlags;                    /* -->: Various control options    */
  336.     SInt16                             ataPBReserved3;                /* Reserved                                        */
  337.     UInt32                             ataPBDeviceID;                /* -->: Device identifier (see ataDeviceID)            */
  338.     UInt32                             ataPBTimeOut;                /* -->: Transaction timeout value    in msec */
  339.     Ptr                             ataPBClientPtr1;            /* Client's storage Ptr 1     */
  340.     Ptr                             ataPBClientPtr2;            /* Client's storage Ptr 2     */
  341.     UInt16                             ataPBState;                    /* Reserved for Manager; Initialize to 0 */
  342.     UInt16                             ataPBSemaphores;            /* Used internally by the manager*/
  343.     SInt32                             ataPBReserved4;                /* Reserved                                        */
  344.                                                                 /* End of cloned common header ataPBHdr*/
  345. };
  346. typedef struct ataPBHeader                ataPBHeader;
  347. /* data request entry structure (16 bytes)*/
  348.  
  349. struct IOBlock {
  350.     UInt8 *                            ataPBBuffer;                /* -->: Data buffer pointer*/
  351.     UInt32                             ataPBByteCount;                /* -->: Data transfer length in bytes*/
  352. };
  353. typedef struct IOBlock                    IOBlock;
  354. /*
  355.    For ATAPI devices the ExtendedPB field is a pointer to the Command Packet
  356.    record which exists of an array of words structured as follows...    <06/15/94>
  357. */
  358.  
  359. struct ATAPICmdPacket {
  360.     SInt16                             atapiPacketSize;            /* Size of command packet in bytes    <06/15/94>*/
  361.     SInt16                             atapiCommandByte[8];        /* The command packet itself    <06/15/94>*/
  362. };
  363. typedef struct ATAPICmdPacket            ATAPICmdPacket;
  364. /* Manager parameter block structure (96 bytes)*/
  365.  
  366. struct ataIOPB {
  367.                                                                 /* Start of cloned common header ataPBHdr*/
  368.     ataPBHeader *                    ataPBLink;                    /* a pointer to the next entry in the queue    */
  369.     UInt16                             ataPBQType;                    /* type byte for safety check*/
  370.     UInt8                             ataPBVers;                    /* -->: parameter block version number; Must be 0x01*/
  371.     UInt8                             ataPBReserved;                /* Reserved                                        */
  372.     Ptr                             ataPBReserved2;                /* Reserved                                        */
  373.     ATACallbackUPP                     ataPBCallbackPtr;            /* -->: Completion Routine Pointer*/
  374.     OSErr                             ataPBResult;                /* <--: Returned result                */
  375.     UInt8                             ataPBFunctionCode;            /* -->: Manager Function Code */
  376.     UInt8                             ataPBIOSpeed;                /* -->: I/O Timing Class            */
  377.     UInt16                             ataPBFlags;                    /* -->: Various control options    */
  378.     SInt16                             ataPBReserved3;                /* Reserved                                        */
  379.     UInt32                             ataPBDeviceID;                /* -->: Device identifier (see ataDeviceID)            */
  380.     UInt32                             ataPBTimeOut;                /* -->: Transaction timeout value    in msec */
  381.     Ptr                             ataPBClientPtr1;            /* Client's storage Ptr 1     */
  382.     Ptr                             ataPBClientPtr2;            /* Client's storage Ptr 2     */
  383.     UInt16                             ataPBState;                    /* Reserved for Manager; Initialize to 0 */
  384.     UInt16                             ataPBSemaphores;            /* Used internally by the manager*/
  385.     SInt32                             ataPBReserved4;                /* Reserved                                        */
  386.                                                                 /* End of cloned common header ataPBHdr*/
  387.     SInt8                             ataPBStatusRegister;        /* <--: Last ATA status image*/
  388.     SInt8                             ataPBErrorRegister;            /* <--: Last ATA error image-valid if lsb of Status set*/
  389.     SInt16                             ataPBReserved5;                /* Reserved*/
  390.     UInt32                             ataPBLogicalBlockSize;        /* -->: Blind transfer size per interrupt (Logical block size)*/
  391.     UInt8 *                            ataPBBuffer;                /* -->: Data buffer pointer*/
  392.     UInt32                             ataPBByteCount;                /* -->: Data transfer length in bytes*/
  393.     UInt32                             ataPBActualTxCount;            /* <--: Actual transfer count*/
  394.     UInt32                             ataPBReserved6;                /* Reserved*/
  395.     ataTaskFile                     ataPBTaskFile;                /* <->:    Device register images*/
  396.     ATAPICmdPacket *                ataPBPacketPtr;                /* -->: ATAPI packet command block pointer (valid with ATAPI bit set)*/
  397.     SInt16                             ataPBReserved7[6];            /* Reserved for future expansion*/
  398. };
  399. typedef struct ataIOPB                    ataIOPB;
  400. /* Parameter block structure for bus and Manager inquiry command*/
  401. /* Manager parameter block structure*/
  402.  
  403. struct ataBusInquiry {
  404.                                                                 /* Start of cloned common header ataPBHdr*/
  405.     ataPBHeader *                    ataPBLink;                    /* a pointer to the next entry in the queue    */
  406.     UInt16                             ataPBQType;                    /* type byte for safety check*/
  407.     UInt8                             ataPBVers;                    /* -->: parameter block version number; Must be 0x01*/
  408.     UInt8                             ataPBReserved;                /* Reserved                                        */
  409.     Ptr                             ataPBReserved2;                /* Reserved                                        */
  410.     ATACallbackUPP                     ataPBCallbackPtr;            /* -->: Completion Routine Pointer*/
  411.     OSErr                             ataPBResult;                /* <--: Returned result                */
  412.     UInt8                             ataPBFunctionCode;            /* -->: Manager Function Code */
  413.     UInt8                             ataPBIOSpeed;                /* -->: I/O Timing Class            */
  414.     UInt16                             ataPBFlags;                    /* -->: Various control options    */
  415.     SInt16                             ataPBReserved3;                /* Reserved                                        */
  416.     UInt32                             ataPBDeviceID;                /* -->: Device identifier (see ataDeviceID)            */
  417.     UInt32                             ataPBTimeOut;                /* -->: Transaction timeout value    in msec */
  418.     Ptr                             ataPBClientPtr1;            /* Client's storage Ptr 1     */
  419.     Ptr                             ataPBClientPtr2;            /* Client's storage Ptr 2     */
  420.     UInt16                             ataPBState;                    /* Reserved for Manager; Initialize to 0 */
  421.     UInt16                             ataPBSemaphores;            /* Used internally by the manager*/
  422.     SInt32                             ataPBReserved4;                /* Reserved                                        */
  423.                                                                 /* End of cloned common header ataPBHdr*/
  424.     UInt16                             ataEngineCount;                /* <--: TBD; zero for now*/
  425.     UInt16                             ataReserved1;                /* Reserved*/
  426.     UInt32                             ataDataTypes;                /* <--: TBD; zero for now*/
  427.     UInt16                             ataIOpbSize;                /* <--: Size of ATA IO PB*/
  428.     UInt16                             ataMaxIOpbSize;                /* <--: TBD; zero for now*/
  429.     UInt32                             ataFeatureFlags;            /* <--: TBD*/
  430.     UInt8                             ataVersionNum;                /* <--: Version number for the HBA*/
  431.     UInt8                             ataHBAInquiry;                /* <--: TBD; zero for now*/
  432.     UInt16                             ataReserved2;                /* Reserved*/
  433.     UInt32                             ataHBAPrivPtr;                /* <--: Ptr to HBA private data area*/
  434.     UInt32                             ataHBAPrivSize;                /* <--: Size of HBA private data area*/
  435.     UInt32                             ataAsyncFlags;                /* <--: Event capability for callback*/
  436.     UInt8                             ataPIOModes;                /* <--: PIO modes supported (bit-significant)*/
  437.     UInt8                             ataUltraDMAModes;            /* <--: Ultra DMA modes supported (b-sig)*/
  438.     UInt8                             ataSingleDMAModes;            /* <--: Single Word DMA modes supported (b-sig)    */
  439.     UInt8                             ataMultiDMAModes;            /* <--: Multiword DMA modes supported (b-sig)*/
  440.     UInt32                             ataReserved4[4];            /* Reserved*/
  441.     SInt8                             ataReserved5[16];            /* TBD*/
  442.     SInt8                             ataHBAVendor[16];            /* <--: Vendor ID of the HBA*/
  443.     SInt8                             ataContrlFamily[16];        /* <--: Family of ATA Controller*/
  444.     SInt8                             ataContrlType[16];            /* <--: Model number of controller*/
  445.     SInt8                             ataXPTversion[4];            /* <--: version number of XPT*/
  446.     SInt8                             ataReserved6[4];            /* Reserved*/
  447.     NumVersion                         ataHBAversion;                /* <--: version number of HBA*/
  448.     UInt8                             ataHBAslotType;                /* <--: type of slot*/
  449.     UInt8                             ataHBAslotNum;                /* <--: slot number of the HBA*/
  450.     UInt16                             ataReserved7;                /* Reserved*/
  451.     UInt32                             ataReserved8;                /* Reserved*/
  452. };
  453. typedef struct ataBusInquiry            ataBusInquiry;
  454. /* Manager parameter block structure*/
  455.  
  456. struct ataMgrInquiry {
  457.                                                                 /* Start of cloned common header ataPBHdr*/
  458.     ataPBHeader *                    ataPBLink;                    /* a pointer to the next entry in the queue    */
  459.     UInt16                             ataPBQType;                    /* type byte for safety check*/
  460.     UInt8                             ataPBVers;                    /* -->: parameter block version number; Must be 0x01*/
  461.     UInt8                             ataPBReserved;                /* Reserved                                        */
  462.     Ptr                             ataPBReserved2;                /* Reserved                                        */
  463.     ATACallbackUPP                     ataPBCallbackPtr;            /* -->: Completion Routine Pointer*/
  464.     OSErr                             ataPBResult;                /* <--: Returned result                */
  465.     UInt8                             ataPBFunctionCode;            /* -->: Manager Function Code */
  466.     UInt8                             ataPBIOSpeed;                /* -->: I/O Timing Class            */
  467.     UInt16                             ataPBFlags;                    /* -->: Various control options    */
  468.     SInt16                             ataPBReserved3;                /* Reserved                                        */
  469.     UInt32                             ataPBDeviceID;                /* -->: Device identifier (see ataDeviceID)            */
  470.     UInt32                             ataPBTimeOut;                /* -->: Transaction timeout value    in msec */
  471.     Ptr                             ataPBClientPtr1;            /* Client's storage Ptr 1     */
  472.     Ptr                             ataPBClientPtr2;            /* Client's storage Ptr 2     */
  473.     UInt16                             ataPBState;                    /* Reserved for Manager; Initialize to 0 */
  474.     UInt16                             ataPBSemaphores;            /* Used internally by the manager*/
  475.     SInt32                             ataPBReserved4;                /* Reserved                                        */
  476.                                                                 /* End of cloned common header ataPBHdr*/
  477.     NumVersion                         ataMgrVersion;                /* Manager Version information*/
  478.     UInt8                             ataMgrPBVers;                /* <--: Manager PB version number supported*/
  479.     UInt8                             Reserved1;                    /* Reserved*/
  480.     UInt16                             ataBusCnt;                    /* <--: Number of ATA buses in the system*/
  481.     UInt16                             ataDevCnt;                    /* <--: Total number of ATA devices detected*/
  482.     UInt8                             ataPioModes;                /* <--: Maximum Programmed I/O speed mode supported*/
  483.     UInt8                             Reserved2;                    /* Reserved*/
  484.     UInt16                             ataIOClkResolution;            /* <--: IO Clock resolution in nsec (Not supported)*/
  485.     UInt8                             ataSingleDMAModes;            /* <--: Single Word DMA modes supported    */
  486.     UInt8                             ataMultiDMAModes;            /* <--: Multiword DMA modes supported*/
  487.     SInt16                             Reserved[16];                /* Reserved for future expansion*/
  488. };
  489. typedef struct ataMgrInquiry            ataMgrInquiry;
  490. /* Parameter block structure for Abort command*/
  491. /* Manager parameter block structure*/
  492.  
  493. struct ataAbort {
  494.                                                                 /* Start of cloned common header ataPBHdr*/
  495.     ataPBHeader *                    ataPBLink;                    /* a pointer to the next entry in the queue    */
  496.     UInt16                             ataPBQType;                    /* type byte for safety check*/
  497.     UInt8                             ataPBVers;                    /* -->: parameter block version number; Must be 0x01*/
  498.     UInt8                             ataPBReserved;                /* Reserved                                        */
  499.     Ptr                             ataPBReserved2;                /* Reserved                                        */
  500.     ATACallbackUPP                     ataPBCallbackPtr;            /* -->: Completion Routine Pointer*/
  501.     OSErr                             ataPBResult;                /* <--: Returned result                */
  502.     UInt8                             ataPBFunctionCode;            /* -->: Manager Function Code */
  503.     UInt8                             ataPBIOSpeed;                /* -->: I/O Timing Class            */
  504.     UInt16                             ataPBFlags;                    /* -->: Various control options    */
  505.     SInt16                             ataPBReserved3;                /* Reserved                                        */
  506.     UInt32                             ataPBDeviceID;                /* -->: Device identifier (see ataDeviceID)            */
  507.     UInt32                             ataPBTimeOut;                /* -->: Transaction timeout value    in msec */
  508.     Ptr                             ataPBClientPtr1;            /* Client's storage Ptr 1     */
  509.     Ptr                             ataPBClientPtr2;            /* Client's storage Ptr 2     */
  510.     UInt16                             ataPBState;                    /* Reserved for Manager; Initialize to 0 */
  511.     UInt16                             ataPBSemaphores;            /* Used internally by the manager*/
  512.     SInt32                             ataPBReserved4;                /* Reserved                                        */
  513.                                                                 /* End of cloned common header ataPBHdr*/
  514.     ataIOPB *                        ataAbortPB;                    /* -->: Parameter block to be aborted*/
  515.     SInt16                             Reserved[22];                /* Reserved for future expansion*/
  516. };
  517. typedef struct ataAbort                    ataAbort;
  518. /* Manager parameter block structure*/
  519.  
  520. struct ATAEventRec {
  521.     UInt16                             ataEventCode;                /* --> ATA event code*/
  522.     UInt16                             ataPhysicalID;                /* --> Physical drive reference*/
  523.     SInt32                             ataDrvrContext;                /* Context pointer saved by driver*/
  524.     UInt32                             ataMarker;                    /* Always 'LOAD'*/
  525.     UInt32                             ataEventRecVersion;            /* Version number of this data structure*/
  526.     UInt32                             ataDeviceType;                /* Device type on bus (valid for load driver only)*/
  527.     UInt16                             ataRefNum;                    /* RefNum of driver (valid for remove driver only)*/
  528. };
  529. typedef struct ATAEventRec                ATAEventRec;
  530. typedef ATAEventRec *                    ATAEventRecPtr;
  531. typedef CALLBACK_API( SInt16 , ATAClientProcPtr )(ATAEventRecPtr ataERPtr);
  532. typedef STACK_UPP_TYPE(ATAClientProcPtr)                         ATAClientUPP;
  533. #if OPAQUE_UPP_TYPES
  534.     EXTERN_API(ATAClientUPP)
  535.     NewATAClientUPP                   (ATAClientProcPtr        userRoutine);
  536.  
  537.     EXTERN_API(void)
  538.     DisposeATAClientUPP               (ATAClientUPP            userUPP);
  539.  
  540.     EXTERN_API(SInt16)
  541.     InvokeATAClientUPP               (ATAEventRecPtr            ataERPtr,
  542.                                     ATAClientUPP            userUPP);
  543.  
  544. #else
  545.     enum { uppATAClientProcInfo = 0x000000E0 };                     /* pascal 2_bytes Func(4_bytes) */
  546.     #define NewATAClientUPP(userRoutine)                             (ATAClientUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppATAClientProcInfo, GetCurrentArchitecture())
  547.     #define DisposeATAClientUPP(userUPP)                             DisposeRoutineDescriptor(userUPP)
  548.     #define InvokeATAClientUPP(ataERPtr, userUPP)                     (SInt16)CALL_ONE_PARAMETER_UPP((userUPP), uppATAClientProcInfo, (ataERPtr))
  549. #endif
  550. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  551. #define NewATAClientProc(userRoutine)                             NewATAClientUPP(userRoutine)
  552. #define CallATAClientProc(userRoutine, ataERPtr)                InvokeATAClientUPP(ataERPtr, userRoutine)
  553. /* Parameter block structure for Driver Register command*/
  554. /* Manager parameter block structure*/
  555.  
  556. struct ataDrvrRegister {
  557.                                                                 /* Start of cloned common header ataPBHdr*/
  558.     ataPBHeader *                    ataPBLink;                    /* a pointer to the next entry in the queue    */
  559.     UInt16                             ataPBQType;                    /* type byte for safety check*/
  560.     UInt8                             ataPBVers;                    /* -->: parameter block version number; Must be 0x01*/
  561.     UInt8                             ataPBReserved;                /* Reserved                                        */
  562.     Ptr                             ataPBReserved2;                /* Reserved                                        */
  563.     ATACallbackUPP                     ataPBCallbackPtr;            /* -->: Completion Routine Pointer*/
  564.     OSErr                             ataPBResult;                /* <--: Returned result                */
  565.     UInt8                             ataPBFunctionCode;            /* -->: Manager Function Code */
  566.     UInt8                             ataPBIOSpeed;                /* -->: I/O Timing Class            */
  567.     UInt16                             ataPBFlags;                    /* -->: Various control options    */
  568.     SInt16                             ataPBReserved3;                /* Reserved                                        */
  569.     UInt32                             ataPBDeviceID;                /* -->: Device identifier (see ataDeviceID)            */
  570.     UInt32                             ataPBTimeOut;                /* -->: Transaction timeout value    in msec */
  571.     Ptr                             ataPBClientPtr1;            /* Client's storage Ptr 1     */
  572.     Ptr                             ataPBClientPtr2;            /* Client's storage Ptr 2     */
  573.     UInt16                             ataPBState;                    /* Reserved for Manager; Initialize to 0 */
  574.     UInt16                             ataPBSemaphores;            /* Used internally by the manager*/
  575.     SInt32                             ataPBReserved4;                /* Reserved                                        */
  576.                                                                 /* End of cloned common header ataPBHdr*/
  577.     SInt16                             ataDrvrRefNum;                /* <->: Driver reference number*/
  578.     UInt16                             ataDrvrFlags;                /* -->: 1 = loader driver if ataPBDeviceID = -1 {PB2}*/
  579.     UInt16                             ataDeviceNextID;            /* <--: used to specified the next drive ID*/
  580.     SInt16                             ataDrvrLoadPriv;            /* Driver loader private storage*/
  581.     ATAClientUPP                     ataEventHandler;            /* <->: Pointer to ATA event callback routine {PB2}*/
  582.     SInt32                             ataDrvrContext;                /* <->: Context data saved by driver {PB2}*/
  583.     SInt32                             ataEventMask;                /* <->: Set to 1 for notification of event {PB2}*/
  584.     SInt16                             Reserved[14];                /* Reserved for future expansion - from [21] {PB2}*/
  585. };
  586. typedef struct ataDrvrRegister            ataDrvrRegister;
  587. /* Parameter block structure for Modify driver event mask command*/
  588.  
  589. struct ataModifyEventMask {
  590.                                                                 /* Start of cloned common header ataPBHdr*/
  591.     ataPBHeader *                    ataPBLink;                    /* a pointer to the next entry in the queue    */
  592.     UInt16                             ataPBQType;                    /* type byte for safety check*/
  593.     UInt8                             ataPBVers;                    /* -->: parameter block version number; Must be 0x01*/
  594.     UInt8                             ataPBReserved;                /* Reserved                                        */
  595.     Ptr                             ataPBReserved2;                /* Reserved                                        */
  596.     ATACallbackUPP                     ataPBCallbackPtr;            /* -->: Completion Routine Pointer*/
  597.     OSErr                             ataPBResult;                /* <--: Returned result                */
  598.     UInt8                             ataPBFunctionCode;            /* -->: Manager Function Code */
  599.     UInt8                             ataPBIOSpeed;                /* -->: I/O Timing Class            */
  600.     UInt16                             ataPBFlags;                    /* -->: Various control options    */
  601.     SInt16                             ataPBReserved3;                /* Reserved                                        */
  602.     UInt32                             ataPBDeviceID;                /* -->: Device identifier (see ataDeviceID)            */
  603.     UInt32                             ataPBTimeOut;                /* -->: Transaction timeout value    in msec */
  604.     Ptr                             ataPBClientPtr1;            /* Client's storage Ptr 1     */
  605.     Ptr                             ataPBClientPtr2;            /* Client's storage Ptr 2     */
  606.     UInt16                             ataPBState;                    /* Reserved for Manager; Initialize to 0 */
  607.     UInt16                             ataPBSemaphores;            /* Used internally by the manager*/
  608.     SInt32                             ataPBReserved4;                /* Reserved                                        */
  609.                                                                 /* End of cloned common header ataPBHdr*/
  610.     SInt32                             ataModifiedEventMask;        /* -->: new event mask value*/
  611.     SInt16                             Reserved[22];                /* Reserved for future expansion*/
  612. };
  613. typedef struct ataModifyEventMask        ataModifyEventMask;
  614. /* 'ataRegMask' field of the ataRegAccess definition*/
  615. enum {
  616.     bATAAltSDevCValid            = 14,                            /* bit number of alternate status/device cntrl valid bit*/
  617.     bATAStatusCmdValid            = 7,                            /* bit number of status/command valid bit*/
  618.     bATASDHValid                = 6,                            /* bit number of ataTFSDH valid bit*/
  619.     bATACylinderHiValid            = 5,                            /* bit number of cylinder high valid bit*/
  620.     bATACylinderLoValid            = 4,                            /* bit number of cylinder low valid bit*/
  621.     bATASectorNumValid            = 3,                            /* bit number of sector number valid bit*/
  622.     bATASectorCntValid            = 2,                            /* bit number of sector count valid bit*/
  623.     bATAErrFeaturesValid        = 1,                            /* bit number of error/features valid bit*/
  624.     bATADataValid                = 0,                            /* bit number of data valid bit*/
  625.     mATAAltSDevCValid            = 1 << bATAAltSDevCValid,        /* alternate status/device control valid*/
  626.     mATAStatusCmdValid            = 1 << bATAStatusCmdValid,        /* status/command valid*/
  627.     mATASDHValid                = 1 << bATASDHValid,            /* ataTFSDH valid*/
  628.     mATACylinderHiValid            = 1 << bATACylinderHiValid,        /* cylinder high valid*/
  629.     mATACylinderLoValid            = 1 << bATACylinderLoValid,        /* cylinder low valid*/
  630.     mATASectorNumValid            = 1 << bATASectorNumValid,        /* sector number valid*/
  631.     mATASectorCntValid            = 1 << bATASectorCntValid,        /* sector count valid*/
  632.     mATAErrFeaturesValid        = 1 << bATAErrFeaturesValid,    /* error/features valid*/
  633.     mATADataValid                = 1 << bATADataValid            /* data valid*/
  634. };
  635.  
  636. /* Parameter block structure for device register access command*/
  637.  
  638. union ataRegValueUnion {
  639.     UInt8                             ataByteRegValue;            /* <->: Byte register value read or to be written*/
  640.     UInt16                             ataWordRegValue;            /* <->: Word register value read or to be written*/
  641. };
  642. typedef union ataRegValueUnion            ataRegValueUnion;
  643. /* Manager parameter block structure*/
  644.  
  645. struct ataRegAccess {
  646.                                                                 /* Start of cloned common header ataPBHdr*/
  647.     ataPBHeader *                    ataPBLink;                    /* a pointer to the next entry in the queue    */
  648.     UInt16                             ataPBQType;                    /* type byte for safety check*/
  649.     UInt8                             ataPBVers;                    /* -->: parameter block version number; Must be 0x01*/
  650.     UInt8                             ataPBReserved;                /* Reserved                                        */
  651.     Ptr                             ataPBReserved2;                /* Reserved                                        */
  652.     ATACallbackUPP                     ataPBCallbackPtr;            /* -->: Completion Routine Pointer*/
  653.     OSErr                             ataPBResult;                /* <--: Returned result                */
  654.     UInt8                             ataPBFunctionCode;            /* -->: Manager Function Code */
  655.     UInt8                             ataPBIOSpeed;                /* -->: I/O Timing Class            */
  656.     UInt16                             ataPBFlags;                    /* -->: Various control options    */
  657.     SInt16                             ataPBReserved3;                /* Reserved                                        */
  658.     UInt32                             ataPBDeviceID;                /* -->: Device identifier (see ataDeviceID)            */
  659.     UInt32                             ataPBTimeOut;                /* -->: Transaction timeout value    in msec */
  660.     Ptr                             ataPBClientPtr1;            /* Client's storage Ptr 1     */
  661.     Ptr                             ataPBClientPtr2;            /* Client's storage Ptr 2     */
  662.     UInt16                             ataPBState;                    /* Reserved for Manager; Initialize to 0 */
  663.     UInt16                             ataPBSemaphores;            /* Used internally by the manager*/
  664.     SInt32                             ataPBReserved4;                /* Reserved                                        */
  665.                                                                 /* End of cloned common header ataPBHdr*/
  666.     UInt16                             ataRegSelect;                /* -->: Device Register Selector*/
  667.                                                                 /*            DataReg            0    */
  668.                                                                 /*            ErrorReg(R) or FeaturesReg(W)    1*/
  669.                                                                 /*            SecCntReg        2*/
  670.                                                                 /*            SecNumReg        3*/
  671.                                                                 /*            CylLoReg        4*/
  672.                                                                 /*            CylHiReg        5*/
  673.                                                                 /*            SDHReg            6*/
  674.                                                                 /*            StatusReg(R) or CmdReg(W)        7*/
  675.                                                                 /*            AltStatus(R) or DevCntr(W)    0E*/
  676.     ataRegValueUnion                 ataRegValue;
  677.                                                                 /* Following fields are valid only if ataRegSelect = 0xFFFF*/
  678.     UInt16                             ataRegMask;                    /* -->: mask for register(s) to update*/
  679.                                                                 /*        bit 0 : data register valid*/
  680.                                                                 /*        bit 1 : error/feaures register valid*/
  681.                                                                 /*        bit 2 : sector count register valid*/
  682.                                                                 /*        bit 3 : sector number register valid*/
  683.                                                                 /*        bit 4 : cylinder low register valid*/
  684.                                                                 /*        bit 5 : cylinder high register valid*/
  685.                                                                 /*        bit 6 : ataTFSDH register valid*/
  686.                                                                 /*        bit 7 : status/command register valid*/
  687.                                                                 /*        bits 8 - 13 : reserved (set to 0)*/
  688.                                                                 /*        bit 14: alternate status / device control reg valid*/
  689.                                                                 /*         bit 15: reserved (set to 0)*/
  690.     ataTaskFile                     ataRegisterImage;            /* <->: register images*/
  691.     UInt8                             ataAltSDevCReg;                /* <->: Alternate status(R) or Device Control(W) register image*/
  692.     UInt8                             Reserved3;                    /* Reserved*/
  693.     SInt16                             Reserved[16];                /* Reserved for future expansion*/
  694. };
  695. typedef struct ataRegAccess                ataRegAccess;
  696. /* Manager parameter block structure    <DP03/10/94>*/
  697.  
  698. struct ataIdentify {
  699.                                                                 /* Start of cloned common header ataPBHdr*/
  700.     ataPBHeader *                    ataPBLink;                    /* a pointer to the next entry in the queue    */
  701.     UInt16                             ataPBQType;                    /* type byte for safety check*/
  702.     UInt8                             ataPBVers;                    /* -->: parameter block version number; Must be 0x01*/
  703.     UInt8                             ataPBReserved;                /* Reserved                                        */
  704.     Ptr                             ataPBReserved2;                /* Reserved                                        */
  705.     ATACallbackUPP                     ataPBCallbackPtr;            /* -->: Completion Routine Pointer*/
  706.     OSErr                             ataPBResult;                /* <--: Returned result                */
  707.     UInt8                             ataPBFunctionCode;            /* -->: Manager Function Code */
  708.     UInt8                             ataPBIOSpeed;                /* -->: I/O Timing Class            */
  709.     UInt16                             ataPBFlags;                    /* -->: Various control options    */
  710.     SInt16                             ataPBReserved3;                /* Reserved                                        */
  711.     UInt32                             ataPBDeviceID;                /* -->: Device identifier (see ataDeviceID)            */
  712.     UInt32                             ataPBTimeOut;                /* -->: Transaction timeout value    in msec */
  713.     Ptr                             ataPBClientPtr1;            /* Client's storage Ptr 1     */
  714.     Ptr                             ataPBClientPtr2;            /* Client's storage Ptr 2     */
  715.     UInt16                             ataPBState;                    /* Reserved for Manager; Initialize to 0 */
  716.     UInt16                             ataPBSemaphores;            /* Used internally by the manager*/
  717.     SInt32                             ataPBReserved4;                /* Reserved                                        */
  718.                                                                 /* End of cloned common header ataPBHdr*/
  719.     UInt16                             Reserved1[4];                /* Reserved.  These are used internally by the Manager*/
  720.     UInt8 *                            ataPBBuffer;                /* Buffer for the identify data (512 bytes)*/
  721.     UInt16                             Reserved2[12];                /* Used internally by the ATA Manager*/
  722.     SInt16                             Reserved3[6];                /* Reserved for future expansion*/
  723. };
  724. typedef struct ataIdentify                ataIdentify;
  725. /* 'ataConfigSetting' field of the Get/Set Device Configuration definition <8/6/94>*/
  726. enum {
  727.     ATAPIpacketDRQ_bit            = 6,                            /* bit number of ATAPI command packet DRQ option*/
  728.     ATAPIpacketDRQ                = 1 << ATAPIpacketDRQ_bit        /* ATAPI command packet DRQ option*/
  729. };
  730.  
  731. /* atapcValid field definition*/
  732. enum {
  733.     bATApcAccessMode            = 0,
  734.     bATApcVcc                    = 1,
  735.     bATApcVpp1                    = 2,
  736.     bATApcVpp2                    = 3,
  737.     bATApcStatus                = 4,
  738.     bATApcPin                    = 5,
  739.     bATApcCopy                    = 6,
  740.     bATApcConfigIndex            = 7,
  741.     bATApcLockUnlock            = 15,
  742.     mATApcAccessMode            = 1 << bATApcAccessMode,
  743.     mATApcVcc                    = 1 << bATApcVcc,
  744.     mATApcVpp1                    = 1 << bATApcVpp1,
  745.     mATApcVpp2                    = 1 << bATApcVpp2,
  746.     mATApcStatus                = 1 << bATApcStatus,
  747.     mATApcPin                    = 1 << bATApcPin,
  748.     mATApcCopy                    = 1 << bATApcCopy,
  749.     mATApcConfigIndex            = 1 << bATApcConfigIndex,
  750.     mATApcLockUnlock            = 1 << bATApcLockUnlock
  751. };
  752.  
  753. /* Device physical type & socket type indicator definition*/
  754. enum {
  755.     kATADeviceUnknown            = 0x00,                            /* no device or type undetermined*/
  756.     kATADeviceATA                = 0x01,                            /* traditional ATA protocol device <7/29/94>*/
  757.     kATADeviceATAPI                = 0x02,                            /* ATAPI protocol device    <7/29/94>*/
  758.     kATADeviceReserved            = 0x03                            /* reserved by Apple (was PCMCIA)*/
  759. };
  760.  
  761. enum {
  762.     kATASocketInternal            = 0x01,                            /* Internal ATA socket*/
  763.     kATASocketMB                = 0x02,                            /* Media Bay socket*/
  764.     kATASocketPCMCIA            = 0x03                            /* PCMCIA socket*/
  765. };
  766.  
  767. /* reserved words at the end of the devConfig structure*/
  768. enum {
  769.     kATAConfigReserved            = 5                                /* number of reserved words at the end*/
  770. };
  771.  
  772. /*
  773.    Get/Set Device Configuration parameter block structure <8/6/94>
  774.    Manager parameter block structure
  775. */
  776.  
  777. struct ataDevConfiguration {
  778.                                                                 /* Start of cloned common header ataPBHdr*/
  779.     ataPBHeader *                    ataPBLink;                    /* a pointer to the next entry in the queue    */
  780.     UInt16                             ataPBQType;                    /* type byte for safety check*/
  781.     UInt8                             ataPBVers;                    /* -->: parameter block version number; Must be 0x01*/
  782.     UInt8                             ataPBReserved;                /* Reserved                                        */
  783.     Ptr                             ataPBReserved2;                /* Reserved                                        */
  784.     ATACallbackUPP                     ataPBCallbackPtr;            /* -->: Completion Routine Pointer*/
  785.     OSErr                             ataPBResult;                /* <--: Returned result                */
  786.     UInt8                             ataPBFunctionCode;            /* -->: Manager Function Code */
  787.     UInt8                             ataPBIOSpeed;                /* -->: I/O Timing Class            */
  788.     UInt16                             ataPBFlags;                    /* -->: Various control options    */
  789.     SInt16                             ataPBReserved3;                /* Reserved                                        */
  790.     UInt32                             ataPBDeviceID;                /* -->: Device identifier (see ataDeviceID)            */
  791.     UInt32                             ataPBTimeOut;                /* -->: Transaction timeout value    in msec */
  792.     Ptr                             ataPBClientPtr1;            /* Client's storage Ptr 1     */
  793.     Ptr                             ataPBClientPtr2;            /* Client's storage Ptr 2     */
  794.     UInt16                             ataPBState;                    /* Reserved for Manager; Initialize to 0 */
  795.     UInt16                             ataPBSemaphores;            /* Used internally by the manager*/
  796.     SInt32                             ataPBReserved4;                /* Reserved                                        */
  797.                                                                 /* End of cloned common header ataPBHdr*/
  798.     SInt32                             ataConfigSetting;            /* <->: Configuration setting*/
  799.                                                                 /*      Bits 3 - 0: Reserved*/
  800.                                                                 /*      Bit 4: Reserved (allowLBAAccess)*/
  801.                                                                 /*      Bit 5: Reserved (allowRWMultiple)*/
  802.                                                                 /*      Bit 6: ATAPIpacketDRQ*/
  803.                                                                 /*        1 = Check for Interrupt DRQ on ATAPI command packet DRQ*/
  804.                                                                 /*        0 = Default: Check only for the assertion of command packet DRQ*/
  805.                                                                 /*      Bits 31 - 7: Reserved*/
  806.     UInt8                             ataPIOSpeedMode;            /* <->: Device access speed in PIO Mode*/
  807.     UInt8                             Reserved3;                    /* Reserved to force word alignment*/
  808.     UInt16                             atapcValid;                    /* <->: Set when pcXXX fields are valid (atapcAccessMode - atapcConfigIndex)*/
  809.                                                                 /*        bit 0 - atapcAccessMode field valid, when set*/
  810.                                                                 /*        bit 1 - atapcVcc field valid, when set*/
  811.                                                                 /*        bit 2 - atapcVpp1 field valid, when set*/
  812.                                                                 /*        bit 3 - atapcVpp2 field valid, when set*/
  813.                                                                 /*        bit 4 - atapcStatus field valid, when set*/
  814.                                                                 /*        bit 5 - atapcPin field valid, when set*/
  815.                                                                 /*        bit 6 - atapcCopy field valid, when set*/
  816.                                                                 /*        bit 7 - atapcConfigIndex field valid, when set*/
  817.                                                                 /*        bits 14-8 - Reserved*/
  818.                                                                 /*        bit 15 - device lock/unlock request (write only)*/
  819.     UInt16                             ataRWMultipleCount;            /* Reserved for future (not supported yet)*/
  820.     UInt16                             ataSectorsPerCylinder;        /* Reserved for future (not supported yet)*/
  821.     UInt16                             ataHeads;                    /* Reserved for future (not supported yet)*/
  822.     UInt16                             ataSectorsPerTrack;            /* Reserved for future (not supported yet)*/
  823.     UInt16                             ataSocketNumber;            /* <--: Socket number used by the CardServices*/
  824.                                                                 /*        0xFF = socket number invalid (Not a CardServices device)*/
  825.                                                                 /*        other = socket number of the device*/
  826.     UInt8                             ataSocketType;                /* <--: Specifies the socket type (get config only)*/
  827.                                                                 /*        00 = Unknown socket*/
  828.                                                                 /*         01 = Internal ATA bus*/
  829.                                                                 /*        02 = Media Bay*/
  830.                                                                 /*        03 = PCMCIA*/
  831.     UInt8                             ataDeviceType;                /* <--: Specifies the device type (get config only)*/
  832.                                                                 /*        00 = Unknown device*/
  833.                                                                 /*        01 = standard ATA device (HD)*/
  834.                                                                 /*        02 = ATAPI device*/
  835.                                                                 /*        03 = PCMCIA ATA device*/
  836.     UInt8                             atapcAccessMode;            /* <->: Access mode: Memory vs. I/O (PCMCIA only)*/
  837.     UInt8                             atapcVcc;                    /* <->: Voltage in tenths of a volt (PCMCIA only)*/
  838.     UInt8                             atapcVpp1;                    /* <->: Voltage in tenths of a volt (PCMCIA only)*/
  839.     UInt8                             atapcVpp2;                    /* <->: Voltage in tenths of a volt (PCMCIA only)*/
  840.     UInt8                             atapcStatus;                /* <->: Card Status register setting (PCMCIA only)*/
  841.     UInt8                             atapcPin;                    /* <->: Card Pin register setting (PCMCIA only)*/
  842.     UInt8                             atapcCopy;                    /* <->: Card Socket/Copy register setting (PCMCIA only)*/
  843.     UInt8                             atapcConfigIndex;            /* <->: Card Option register setting (PCMCIA only)*/
  844.     UInt8                             ataSingleDMASpeed;            /* <->: Single Word DMA Timing Class*/
  845.     UInt8                             ataMultiDMASpeed;            /* <->: Multiple Word DMA Timing Class*/
  846.     UInt16                             ataPIOCycleTime;            /* <->:Cycle time for PIO mode*/
  847.     UInt16                             ataMultiCycleTime;            /* <->:Cycle time for Multiword DMA mode*/
  848.     UInt8                             ataUltraDMASpeed;            /* <-> Ultra DMA timing class*/
  849.     UInt8                             reserved2;                    /* reserved*/
  850.     UInt16                             ataUltraCycleTime;            /* <-> Cycle time for Ultra DMA mode*/
  851.     UInt16                             Reserved1[5];                /* Reserved for future*/
  852. };
  853. typedef struct ataDevConfiguration        ataDevConfiguration;
  854. /* Get Card Location Icon/Text    <SM4>*/
  855. enum {
  856.     kATALargeIconHFS            = 0x0001,                        /* Large B&W icon with mask (HFS)*/
  857.     kATALargeIconProDOS            = 0x0081                        /* Large B&W icon with mask (ProDOS)*/
  858. };
  859.  
  860. /* Manager parameter block structure*/
  861.  
  862. struct ataLocationData {
  863.                                                                 /* Start of cloned common header ataPBHdr*/
  864.     ataPBHeader *                    ataPBLink;                    /* a pointer to the next entry in the queue    */
  865.     UInt16                             ataPBQType;                    /* type byte for safety check*/
  866.     UInt8                             ataPBVers;                    /* -->: parameter block version number; Must be 0x01*/
  867.     UInt8                             ataPBReserved;                /* Reserved                                        */
  868.     Ptr                             ataPBReserved2;                /* Reserved                                        */
  869.     ATACallbackUPP                     ataPBCallbackPtr;            /* -->: Completion Routine Pointer*/
  870.     OSErr                             ataPBResult;                /* <--: Returned result                */
  871.     UInt8                             ataPBFunctionCode;            /* -->: Manager Function Code */
  872.     UInt8                             ataPBIOSpeed;                /* -->: I/O Timing Class            */
  873.     UInt16                             ataPBFlags;                    /* -->: Various control options    */
  874.     SInt16                             ataPBReserved3;                /* Reserved                                        */
  875.     UInt32                             ataPBDeviceID;                /* -->: Device identifier (see ataDeviceID)            */
  876.     UInt32                             ataPBTimeOut;                /* -->: Transaction timeout value    in msec */
  877.     Ptr                             ataPBClientPtr1;            /* Client's storage Ptr 1     */
  878.     Ptr                             ataPBClientPtr2;            /* Client's storage Ptr 2     */
  879.     UInt16                             ataPBState;                    /* Reserved for Manager; Initialize to 0 */
  880.     UInt16                             ataPBSemaphores;            /* Used internally by the manager*/
  881.     SInt32                             ataPBReserved4;                /* Reserved                                        */
  882.                                                                 /* End of cloned common header ataPBHdr*/
  883.     SInt16                             ataIconType;                /* -->: icon type specifier*/
  884.                                                                 /*         1 = Large B&W icon with mask (256 bytes)*/
  885.                                                                 /*        0x81 = Same as 1, but ProDOS icon*/
  886.     SInt16                             ataIconReserved;            /* Reserved to be longword aligned*/
  887.     SInt8 *                            ataLocationIconPtr;            /* -->: Icon Data buffer pointer*/
  888.     SInt8 *                            ataLocationStringPtr;        /* -->: Icon String buffer pointer*/
  889.     UInt16                             Reserved1[18];                /* Reserved for future*/
  890. };
  891. typedef struct ataLocationData            ataLocationData;
  892. /* ataOSType available*/
  893. enum {
  894.     kATAddTypeMacOS                = 0x0001                        /* Blue Mac O/S ddType value*/
  895. };
  896.  
  897. /* The parameter block definition for all other ATA Manager functions.*/
  898.  
  899.  
  900. struct ataGeneric {
  901.                                                                 /* Start of cloned common header ataPBHdr*/
  902.     ataPBHeader *                    ataPBLink;                    /* a pointer to the next entry in the queue    */
  903.     UInt16                             ataPBQType;                    /* type byte for safety check*/
  904.     UInt8                             ataPBVers;                    /* -->: parameter block version number; Must be 0x01*/
  905.     UInt8                             ataPBReserved;                /* Reserved                                        */
  906.     Ptr                             ataPBReserved2;                /* Reserved                                        */
  907.     ATACallbackUPP                     ataPBCallbackPtr;            /* -->: Completion Routine Pointer*/
  908.     OSErr                             ataPBResult;                /* <--: Returned result                */
  909.     UInt8                             ataPBFunctionCode;            /* -->: Manager Function Code */
  910.     UInt8                             ataPBIOSpeed;                /* -->: I/O Timing Class            */
  911.     UInt16                             ataPBFlags;                    /* -->: Various control options    */
  912.     SInt16                             ataPBReserved3;                /* Reserved                                        */
  913.     UInt32                             ataPBDeviceID;                /* -->: Device identifier (see ataDeviceID)            */
  914.     UInt32                             ataPBTimeOut;                /* -->: Transaction timeout value    in msec */
  915.     Ptr                             ataPBClientPtr1;            /* Client's storage Ptr 1     */
  916.     Ptr                             ataPBClientPtr2;            /* Client's storage Ptr 2     */
  917.     UInt16                             ataPBState;                    /* Reserved for Manager; Initialize to 0 */
  918.     UInt16                             ataPBSemaphores;            /* Used internally by the manager*/
  919.     SInt32                             ataPBReserved4;                /* Reserved                                        */
  920.                                                                 /* End of cloned common header ataPBHdr*/
  921.     UInt16                             Reserved[24];                /* Reserved for future*/
  922. };
  923. typedef struct ataGeneric                ataGeneric;
  924.  
  925. union ataPB {
  926.     ataIOPB                         ataIOParamBlock;            /* parameter block for I/O*/
  927.     ataBusInquiry                     ataBIParamBlock;            /* parameter block for bus inquiry*/
  928.     ataMgrInquiry                     ataMIParamBlock;            /* parameter block for Manager inquiry*/
  929.     ataAbort                         ataAbortParamBlock;            /* parameter block for abort*/
  930.     ataDrvrRegister                 ataDRParamBlock;            /* parameter block for driver register*/
  931.     ataModifyEventMask                 ataMEParamBlock;            /* parameter block for event mask modify*/
  932.     ataRegAccess                     ataRAParamBlock;            /* parameter block for register access*/
  933.     ataIdentify                     ataDIParamBlock;            /* parameter block for drive identify*/
  934.     ataDevConfiguration             ataDCParamBlock;            /* parameter block for device configuration*/
  935.     ataLocationData                 ataLDParamBlock;            /* parameter block for location icon data*/
  936.                                                                 /*ataManagerInit    ataInitParamBlock;        // parameter block for Manager initialization*/
  937.                                                                 /*ataManagerShutDn    ataSDParamBlock;        // parameter block for Manager shutdown*/
  938.                                                                 /*ataDrvrLoad        ataDLParamBlock;        // parameter block for Driver loading*/
  939.     ataGeneric                         ataGenericParamBlock;        /* parameter block for all other functions*/
  940. };
  941. typedef union ataPB                        ataPB;
  942. /* The ATA Event codes...*/
  943. enum {
  944.     kATANullEvent                = 0x00,                            /* Just kidding -- nothing happened*/
  945.     kATAOnlineEvent                = 0x01,                            /* An ATA device has come online*/
  946.     kATAOfflineEvent            = 0x02,                            /* An ATA device has gone offline*/
  947.     kATARemovedEvent            = 0x03,                            /* An ATA device has been removed from the bus*/
  948.     kATAResetEvent                = 0x04,                            /* Someone gave a hard reset to the drive*/
  949.     kATAOfflineRequest            = 0x05,                            /* Someone requesting to offline the drive*/
  950.     kATAEjectRequest            = 0x06,                            /* Someone requesting to eject the drive*/
  951.     kATAUpdateEvent                = 0x07,                            /* Potential configuration change reported by CardServices <SM4>*/
  952.     kATATaskTimeRequest            = 0x08,                            /* The manager is requesting to be called at Task Time*/
  953.     kATALoadDriverNow            = 0x09,                            /* Load the driver for the given bus immediately*/
  954.     kATAPIResetEvent            = 0x0A,                            /* Someone gave a ATAPI reset to the drive*/
  955.                                                                 /* The following describes bit definitions in the eventMask field of ataDrvrRegister*/
  956.     bATANullEvent                = 1 << kATANullEvent,            /* null event bit*/
  957.     bATAOnlineEvent                = 1 << kATAOnlineEvent,            /* online event bit*/
  958.     bATAOfflineEvent            = 1 << kATAOfflineEvent,        /* offline event bit*/
  959.     bATARemovedEvent            = 1 << kATARemovedEvent,        /* removed event bit*/
  960.     bATAResetEvent                = 1 << kATAResetEvent,            /* ATA reset event bit*/
  961.     bATAOfflineRequest            = 1 << kATAOfflineRequest,        /* offline request event bit*/
  962.     bATAEjectRequest            = 1 << kATAEjectRequest,        /* eject request event bit*/
  963.     bATAUpdateEvent                = 1 << kATAUpdateEvent,            /* configuration update event bit*/
  964.     bATAPIResetEvent            = 1 << kATAPIResetEvent            /* ATAPI reset event bit*/
  965. };
  966.  
  967. enum {
  968.     kATAEventMarker                = FOUR_CHAR_CODE('LOAD'),        /* Marker for the event data structure*/
  969.     kATAEventVersion1            = 0x00000001                    /* Version 1 of the event structure*/
  970. };
  971.  
  972. typedef CALLBACK_API( OSErr , ATADispatchProcPtr )(ataPB *pb);
  973. typedef STACK_UPP_TYPE(ATADispatchProcPtr)                         ATADispatchUPP;
  974. #if OPAQUE_UPP_TYPES
  975.     EXTERN_API(ATADispatchUPP)
  976.     NewATADispatchUPP               (ATADispatchProcPtr        userRoutine);
  977.  
  978.     EXTERN_API(void)
  979.     DisposeATADispatchUPP           (ATADispatchUPP            userUPP);
  980.  
  981.     EXTERN_API(OSErr)
  982.     InvokeATADispatchUPP           (ataPB *                    pb,
  983.                                     ATADispatchUPP            userUPP);
  984.  
  985. #else
  986.     enum { uppATADispatchProcInfo = 0x000000E0 };                     /* pascal 2_bytes Func(4_bytes) */
  987.     #define NewATADispatchUPP(userRoutine)                             (ATADispatchUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppATADispatchProcInfo, GetCurrentArchitecture())
  988.     #define DisposeATADispatchUPP(userUPP)                             DisposeRoutineDescriptor(userUPP)
  989.     #define InvokeATADispatchUPP(pb, userUPP)                         (OSErr)CALL_ONE_PARAMETER_UPP((userUPP), uppATADispatchProcInfo, (pb))
  990. #endif
  991. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  992. #define NewATADispatchProc(userRoutine)                         NewATADispatchUPP(userRoutine)
  993. #define CallATADispatchProc(userRoutine, pb)                    InvokeATADispatchUPP(pb, userRoutine)
  994. EXTERN_API( SInt16 )
  995. ataManager                        (ataPB *                pb)                                    ONEWORDINLINE(0xAAF1);
  996.  
  997. /* Device Error codes: 0xDB42 - 0xDB5F    */
  998.  
  999. enum {
  1000.     ATABaseErrCode                = -9406,                        /* Base error code - 0xDB42    */
  1001.     ioPending                    = 1,                            /* Asynch I/O in progress status*/
  1002.     AT_NRdyErr                    = ATABaseErrCode + 0x01,        /* 0xDB43: Drive not Ready */
  1003.     AT_IDNFErr                    = ATABaseErrCode + 0x02,        /* 0xDB44: ID not found */
  1004.     AT_DMarkErr                    = ATABaseErrCode + 0x03,        /* 0xDB45: Data mark not found */
  1005.     AT_BadBlkErr                = ATABaseErrCode + 0x04,        /* 0xDB46: Bad Block */
  1006.     AT_CorDataErr                = ATABaseErrCode + 0x05,        /* 0xDB47: Data was corrected */
  1007.     AT_UncDataErr                = ATABaseErrCode + 0x06,        /* 0xDB48: Data was not corrected */
  1008.     AT_SeekErr                    = ATABaseErrCode + 0x07,        /* 0xDB49: Seek error */
  1009.     AT_WrFltErr                    = ATABaseErrCode + 0x08,        /* 0xDB4A: Write fault */
  1010.     AT_RecalErr                    = ATABaseErrCode + 0x09,        /* 0xDB4B: Recalibrate failed */
  1011.     AT_AbortErr                    = ATABaseErrCode + 0x0A,        /* 0xDB4C: Command aborted by drive */
  1012.     AT_MCErr                    = ATABaseErrCode + 0x0C,        /* 0xDB4E: Media Changed error*/
  1013.     ATAPICheckErr                = ATABaseErrCode + 0x0D,        /* 0xDB4F: ATAPI Check condition <06/15/94>*/
  1014.     AT_UltraDMAiCRCErr            = ATABaseErrCode + 0x0E,        /* 0xDB50: CRC error during Ultra DMA xfer */
  1015.                                                                 /* System error codes...Custom Driver Error Codes 0xDB60 - 0xDB6F*/
  1016.     DRVRCantAllocate            = ATABaseErrCode + 0x1E,        /* 0xDB60: Allocation error during initialization*/
  1017.     NoATAMgr                    = ATABaseErrCode + 0x1F,        /* 0xDB61: MgrInquiry failed => No ATA Manager*/
  1018.     ATAInitFail                    = ATABaseErrCode + 0x20,        /* 0xDB62: Mgr Initialization failed*/
  1019.     ATABufFail                    = ATABaseErrCode + 0x21,        /* 0xDB63: Device buffer test failure*/
  1020.     ATADevUnsupported            = ATABaseErrCode + 0x22,        /* 0xDB64: Device type not supported*/
  1021.     ATAEjectDrvErr                = ATABaseErrCode + 0x23,        /* 0xDB65: Could not eject the drive*/
  1022.                                                                 /* Manager Error Codes 0xDB70 - 0xDB8F*/
  1023.     ATAMgrNotInitialized        = ATABaseErrCode + 0x2E,        /* 0xDB70: Mgr has not been initialized*/
  1024.     ATAPBInvalid                = ATABaseErrCode + 0x2F,        /* 0xDB71: The bus base address couldn't be found*/
  1025.     ATAFuncNotSupported            = ATABaseErrCode + 0x30,        /* 0xDB72: An unknown function code specified*/
  1026.     ATABusy                        = ATABaseErrCode + 0x31,        /* 0xDB73: Selected device is busy*/
  1027.     ATATransTimeOut                = ATABaseErrCode + 0x32,        /* 0xDB74: Transaction timeout detected*/
  1028.     ATAReqInProg                = ATABaseErrCode + 0x33,        /* 0xDB75: Channel busy; channel is processing another cmd*/
  1029.     ATAUnknownState                = ATABaseErrCode + 0x34,        /* 0xDB76: Device status register reflects an unknown state*/
  1030.     ATAQLocked                    = ATABaseErrCode + 0x35,        /* 0xDB77: I/O Queue is locked due to previous I/O error.*/
  1031.     ATAReqAborted                = ATABaseErrCode + 0x36,        /* 0xDB78: The I/O queue entry was aborted due to an abort req.*/
  1032.                                                                 /*            or due to Manager shutdown.*/
  1033.     ATAUnableToAbort            = ATABaseErrCode + 0x37,        /* 0xDB79: The I/O queue entry could not be aborted.*/
  1034.     ATAAbortedDueToRst            = ATABaseErrCode + 0x38,        /* 0xDB7A: Request aborted due to a device reset command.*/
  1035.     ATAPIPhaseErr                = ATABaseErrCode + 0x39,        /* 0xDB7B: Unexpected phase - oooIS THIS VALID ERROR??? <06/15/94>*/
  1036.     ATAPITxCntErr                = ATABaseErrCode + 0x3A,        /* 0xDB7C: Overrun/Underrun condition detected*/
  1037.     ATANoClientErr                = ATABaseErrCode + 0x3B,        /* 0xDB7D: No client present to handle the event*/
  1038.     ATAInternalErr                = ATABaseErrCode + 0x3C,        /* 0xDB7E: MagnumOpus returned an error*/
  1039.     ATABusErr                    = ATABaseErrCode + 0x3D,        /* 0xDB7F: Bus error detected on I/O    */
  1040.     AT_NoAddrErr                = ATABaseErrCode + 0x3E,        /* 0xDB80: Invalid AT base adress */
  1041.     DriverLocked                = ATABaseErrCode + 0x3F,        /* 0xDB81: Current driver must be removed before adding another*/
  1042.     CantHandleEvent                = ATABaseErrCode + 0x40,        /* 0xDB82: Particular event couldn't be handled (call others)*/
  1043.     ATAMgrMemoryErr                = ATABaseErrCode + 0x41,        /* 0xDB83: Manager memory allocation error    */
  1044.     ATASDFailErr                = ATABaseErrCode + 0x42,        /* 0xDB84: Shutdown failure                */
  1045.     ATAXferParamErr                = ATABaseErrCode + 0x43,        /* 0xDB85: I/O xfer parameters inconsistent */
  1046.     ATAXferModeErr                = ATABaseErrCode + 0x44,        /* 0xDB86: I/O xfer mode not supported */
  1047.     ATAMgrConsistencyErr        = ATABaseErrCode + 0x45,        /* 0XDB87: Manager detected internal inconsistency. */
  1048.     ATADmaXferErr                = ATABaseErrCode + 0x46,        /* 0XDB88: fatal error in DMA side of transfer */
  1049.                                                                 /* Driver loader error Codes 0xDB90 - 0xDBA5*/
  1050.     ATAInvalidDrvNum            = ATABaseErrCode + 0x4E,        /* 0xDB90: Invalid drive number from event*/
  1051.     ATAMemoryErr                = ATABaseErrCode + 0x4F,        /* 0xDB91: Memory allocation error*/
  1052.     ATANoDDMErr                    = ATABaseErrCode + 0x50,        /* 0xDB92: No DDM found on media    */
  1053.     ATANoDriverErr                = ATABaseErrCode + 0x51            /* 0xDB93: No driver found on the media    */
  1054. };
  1055.  
  1056. /* ------------------------    Version 1 definition -------------------------------    */
  1057. enum {
  1058.     v1ATABaseErrCode            = 0x0700,                        /* This needs a home somewhere*/
  1059.     v1AT_NRdyErr                = 0x01 - v1ATABaseErrCode,        /* 0xF901: -0x1DBE */
  1060.     v1AT_IDNFErr                = 0x04 - v1ATABaseErrCode,        /* 0xF904: -0x1DC0 */
  1061.     v1AT_DMarkErr                = 0x05 - v1ATABaseErrCode,        /* 0xF905: -0x1DC0 */
  1062.     v1AT_BadBlkErr                = 0x06 - v1ATABaseErrCode,        /* 0xF906: -0x1DC0 */
  1063.     v1AT_CorDataErr                = 0x07 - v1ATABaseErrCode,        /* 0xF907: -0x1DC0 */
  1064.     v1AT_UncDataErr                = 0x08 - v1ATABaseErrCode,        /* 0xF908: -0x1DC0 */
  1065.     v1AT_SeekErr                = 0x09 - v1ATABaseErrCode,        /* 0xF909: -0x1DC0 */
  1066.     v1AT_WrFltErr                = 0x0A - v1ATABaseErrCode,        /* 0xF90A: -0x1DC0 */
  1067.     v1AT_RecalErr                = 0x0B - v1ATABaseErrCode,        /* 0xF90B: -0x1DC0 */
  1068.     v1AT_AbortErr                = 0x0C - v1ATABaseErrCode,        /* 0xF90C: -0x1DC0 */
  1069.     v1AT_NoAddrErr                = 0x0D - v1ATABaseErrCode,        /* 0xF90D: -0x1D8D */
  1070.     v1AT_MCErr                    = 0x0E - v1ATABaseErrCode,        /* 0xF90E: -0x1DC0*/
  1071.                                                                 /* System error codes...Custom Driver Error Codes*/
  1072.     v1DRVRCantAllocate            = -(v1ATABaseErrCode + 1),        /* 0xF8FF: -0x1D9F*/
  1073.     v1NoATAMgr                    = -(v1ATABaseErrCode + 2),        /* 0xF8FE: -0x1D9D*/
  1074.     v1ATAInitFail                = -(v1ATABaseErrCode + 3),        /* 0xF8FD: -0x1D9B*/
  1075.     v1ATABufFail                = -(v1ATABaseErrCode + 4),        /* 0xF8FC: -0x1D99*/
  1076.     v1ATADevUnsupported            = -(v1ATABaseErrCode + 5),        /* 0xF8FB: -0x1c97*/
  1077.                                                                 /* Manager Error Codes*/
  1078.     v1ATAMgrNotInitialized        = -(v1ATABaseErrCode + 10),        /* 0xF8F6: -0x1D86*/
  1079.     v1ATAPBInvalid                = -(v1ATABaseErrCode + 11),        /* 0xF8F5: -0x1D84*/
  1080.     v1ATAFuncNotSupported        = -(v1ATABaseErrCode + 12),        /* 0xF8F4: -0x1D82*/
  1081.     v1ATABusy                    = -(v1ATABaseErrCode + 13),        /* 0xF8F3: -0x1D80*/
  1082.     v1ATATransTimeOut            = -(v1ATABaseErrCode + 14),        /* 0xF8F2: -0x1D7E*/
  1083.     v1ATAReqInProg                = -(v1ATABaseErrCode + 15),        /* 0xF8F1: -0x1D7C*/
  1084.     v1ATAUnknownState            = -(v1ATABaseErrCode + 16),        /* 0xF8F0: -0x1D7A*/
  1085.     v1ATAQLocked                = -(v1ATABaseErrCode + 17),        /* 0xF8EF: -0x1D78*/
  1086.     v1ATAReqAborted                = -(v1ATABaseErrCode + 18),        /* 0xF8EE: -0x1D76*/
  1087.     v1ATAUnableToAbort            = -(v1ATABaseErrCode + 19),        /* 0xF8ED: -0x1D74*/
  1088.     v1ATAAbortedDueToRst        = -(v1ATABaseErrCode + 20)        /* 0xF8EC: -0x1D72*/
  1089. };
  1090.  
  1091.  
  1092.  
  1093. #if PRAGMA_STRUCT_ALIGN
  1094.     #pragma options align=reset
  1095. #elif PRAGMA_STRUCT_PACKPUSH
  1096.     #pragma pack(pop)
  1097. #elif PRAGMA_STRUCT_PACK
  1098.     #pragma pack()
  1099. #endif
  1100.  
  1101. #ifdef PRAGMA_IMPORT_OFF
  1102. #pragma import off
  1103. #elif PRAGMA_IMPORT
  1104. #pragma import reset
  1105. #endif
  1106.  
  1107. #ifdef __cplusplus
  1108. }
  1109. #endif
  1110.  
  1111. #endif /* __ATA__ */
  1112.  
  1113.